/**
 * 磁铁
 */
Magnet = Widget.extend({
	ctor:function(){
		this._super();
		this.init();
		this.setTag(TAG_MAGNET);
	},
	init:function(){
		var magnet = new Button(this, 8, TAG_MAGNET_MAGNET, "#magnet.png", this.callback);
		magnet.setScale(0.8);
		magnet.setRotation(45);
		var move1=cc.moveTo(0.6, cc.p(20,0));
		var move2=cc.moveTo(0.6, cc.p(0,0));		
		var seq=cc.sequence(cc.delayTime(0.8),cc.callFunc(function() {
			this.absorb();
		}, this),cc.delayTime(0.4),move1,move2,move1,cc.callFunc(function() {
			var show=new ShowTip("铁粉能被磁铁吸引，\n硫粉不能被磁铁吸引" ,cc.p(1030,350));
			gg.flow.next();
		}, this));
		magnet.runAction(seq);
		

		this.callNext = cc.callFunc(function(){
			gg.flow.next();
		}, this);
		this.callNext.retain();
	},
	absorb:function(){
		var fe=this.getParent().getChildByTag(TAG_PAPER).getChildByTag(TAG_FILTER).getChildByTag(TAG_FILTER_FE);
		var mov=cc.moveTo(0.4, cc.p(28,63));
		var rot=cc.rotateTo(0.4, -45);
		var sca=cc.scaleTo(0.4, 1, 1);
		var spa=cc.spawn(mov,rot,sca);
		
		var move1=cc.moveTo(0.6, cc.p(48,63));
		var move2=cc.moveTo(0.6, cc.p(28,63));
		var seq=cc.sequence(spa,move1,move2,move1);
		fe.runAction(seq);
	},
	rotateBody:function(obj){

	},
	callback:function(p){
		switch(p.getTag()){
		case TAG_SPOON_SPOON:

			break;
		}
	},
	actionDone:function(p){
		switch(p.getTag()){
		case TAG_SPOON_SPOON:
			break;
		}
	},
	onExit:function(){
		this._super();
		this.callNext.release();
	}
});